<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <h1 class="text-center ">
                预存款规则信息编辑页面
            </h1>
            <h3 class="text-right text-success">
                欢迎您:张三
            </h3>
            <form id="tripForm" class="form-horizontal" role="form">
                <input type="hidden" value="${prefundRule.rid}" name="rid"/>
                <div class="form-group">
                    <label for="ruleName" class="col-sm-2 control-label">规则名称</label>
                    <div class="col-sm-10">
                        <input name="ruleName" id="ruleName" type="text" class="form-control"
                        value="${prefundRule.ruleName}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="ruleType" class="col-sm-2 control-label">规则类型</label>
                    <div class="col-sm-10">
                        <input name="ruleType" id="ruleType" type="text" class="form-control"
                               value="${prefundRule.ruleType}"/>
                    </div>
                </div>


                <div class="form-group">
                    <label for="brand" class="col-sm-2 control-label">适用品牌</label>
                    <div class="col-sm-10">
                        <input name="brand" id="brand" type="text" class="form-control"
                               value="${prefundRule.brand}"/>
                    </div>
                </div>

                <div class="form-group">
                    <label for="prefund" class="col-sm-2 control-label">预存金额</label>
                    <div class="col-sm-10">
                        <input name="prefund" id="prefund" type="text" class="form-control"
                               value="${prefundRule.prefund?c}"/>
                    </div>
                </div>

                <div class="form-group">
                    <label for="giveFund" class="col-sm-2 control-label">赠送金额</label>
                    <div class="col-sm-10">
                        <input name="giveFund" id="giveFund" type="text" class="form-control"
                               value="${prefundRule.giveFund?c}" />
                    </div>
                </div>

                <div class="form-group">
                    <label for="beginDate" class="col-sm-2 control-label">生效时间</label>
                    <div class="col-sm-10">
                        <input name="beginDate" id="beginDate" type="date" class="form-control"
                               value="${prefundRule.beginDate?string('yyyy-MM-dd')}"/>
                    </div>
                </div>


                <div class="form-group">
                    <label for="endDate" class="col-sm-2 control-label">失效时间</label>
                    <div class="col-sm-10">
                        <input name="endDate" id="endDate" type="date" class="form-control"
                               value="${prefundRule.endDate?string('yyyy-MM-dd')}"/>
                    </div>
                </div>

                <div class="form-group">
                    <label for="giveFund" class="col-sm-2 control-label">状态</label>
                    <div class="col-sm-10">
                        <select name="state" class="selector">
                            <option value="0">请选择菜单</option>
                            <option  <#if prefundRule.state=="未开始" >selected</#if>>未开始</option>
                            <option  <#if prefundRule.state=="已结束" >selected</#if>>已结束</option>
                            <option  <#if prefundRule.state== "进行中">selected</#if>>进行中</option>
                        </select>
                    </div>
                </div>


                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="button" onclick="tripSubmit()" class="btn btn-default">保存</button>
                        <button type="button" class="btn btn-default" onclick="history.back()">返回</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="/static/js/jquery-1.8.0.min.js" ></script>
<script>
    // 编辑信息
    function tripSubmit(){
        //1. 获取form表单中的全部内容
        var data = $("#tripForm").serialize(); // 将携带name属性的表单项拼接为key=value&key=value..
        //2. 发送ajax请求到后台,并传递全部的参数.
        $.post(
            "/prefundRule/edit",
            data,
            function(result){
                if(result.code == 0){
                    location.href = "/prefundRule/list";
                }
                else {
                    alert(result.msg);
                }
            },
            "json"
        );
    }


</script>
</body>
</html>